<?php
App::uses('PaymentAppModel', 'Payment.Model');
/**
 * PluginPaymentStatus Model
 *
 * @property PaymentGateway $PaymentGateway
 */
class PaymentStatus extends PaymentAppModel {

/**
 * Use table
 *
 * @var mixed False or table name
 */
	public $useTable = 'plugin_payment_status';

/**
 * Display field
 *
 * @var string
 */
	public $displayField = 'text';

/**
 * Validation rules
 *
 * @var array
 */
	public $validate = array(
		'payment_gateway_id' => array(
			'numeric' => array(
				'rule' => array('numeric'),
				//'message' => 'Your custom message here',
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		),
		'code' => array(
			'notEmpty' => array(
				'rule' => array('notEmpty'),
				//'message' => 'Your custom message here',
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		),
		'text' => array(
			'notEmpty' => array(
				'rule' => array('notEmpty'),
				//'message' => 'Your custom message here',
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		),
	);

	//The Associations below have been created with all possible keys, those that are not needed can be removed

/**
 * belongsTo associations
 *
 * @var array
 */
	public $belongsTo = array(
		'PaymentGateway' => array(
			'className' => 'PaymentGateway',
			'foreignKey' => 'payment_gateway_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		)
	);
	
	public function getIdFromGatewayAndCode($gateway, $code){
		$data = $this->find('first', array('conditions'=>array('payment_gateway_id'=>$gateway, 'code'=>$code)));
		return $data[$this->alias]['id'];
	}
	
	public function idsPagos(){
		return array(3,4,9);
	}
	
	public function idsAguardando(){
		return array(0,1,2,8);
	}
	
	public function idsCancelados(){
		return array(7);
	}
}
